<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>当前补助信息</title>
<link href="../easyui/themes/default/easyui.css" rel="stylesheet"
	type="text/css" />
<link href="../easyui/themes/icon.css" rel="stylesheet" type="text/css" />
<!-- <link rel="stylesheet" type="text/css" href="../easyui/demo/demo.css"> -->
<script src="../easyui/jquery.min.js" type="text/javascript"></script>
<script src="../easyui/jquery.easyui.min.js" type="text/javascript"></script>
<script src="../js/jquery-form.js" type="text/javascript"></script>
<script type="text/javascript"
	src="../easyui/locale/easyui-lang-zh_CN.js" charset="utf-8"></script>
<script type="text/javascript">
	//批量导入按钮事件
	function upload() {
		//alert($("#searchUnitId").val());
		$('#dlg_upload').dialog('open').dialog('setTitle', '上传文件');
	}
	//上传excel
	function uploadExcel() {
		//得到上传文件的全路径  
		var fileName = $('#uploadExcel').val();
		//alert(fileName);

		//进行文件后缀校验
		if (fileName == "") {
			$.messager.alert('提示', '请选择上传文件！', 'info');
		} else {
			//对文件格式进行校验  
			var d1 = /\.[^\.]+$/.exec(fileName);
			if (d1 == ".xls" || d1 == ".xlsx") {
				var options = {
					url : '/studentmanagement/yh/BZ_tmp/upload.do',
					success : function(data) {
						$.messager.alert('Info', data.message, 'info');
						$('#list_data').datagrid('reload'); // reload the user data
						$('#uploadExcel').val('');
					},
					error : function() {
						$.messager.alert('Error', "服务器内部错误", 'error');
					}
				};
				$('#fm_upload').ajaxSubmit(options);
			} else {
				$.messager.alert('错误', '请选择excel文件上传！', 'error');
				$('#uploadExcel').val('');
			}
		}

	}
	/* function add() {
		$('#dlg').dialog('open').dialog('setTitle', '修改');
	} */
	//修改信息
	function edit(index) {
		var row = $('#list_data').datagrid('getData').rows[index];
		//alert(row);
		$('#dlg').dialog('open').dialog('setTitle', '修改');
		$('#fm').form('clear');
		$('#fm').form('load', row);
		url = '/studentmanagement/yh/BZ_tmp/update.do';
	}
	//删除一条助管信息
	function _delete(index) {
		var row = $('#list_data').datagrid('getData').rows[index];
		if (row) {
			$.messager.confirm('提示', '确定删除吗?', function(r) {
				if (r) {
					$.post('/studentmanagement/yh/BZ_tmp/delete.do', {
						id : row.id
					}, function(result) {
						if (result.status == 1) {
							$('#list_data').datagrid('reload'); // reload the user data
						} else {
							$.messager.show({ // show error message
								title : 'Error',
								msg : result.message
							});
						}
					}, 'json');
				}
			});
		}
	}
	//保存修改
	function save() {
		$('#fm').form('submit', {
			url : url,
			onSubmit : function() {
				return $(this).form('validate');
			},
			success : function(result) {
				if (result.status == 0) {
					$.messager.show({
						title : 'Error',
						msg : result.message
					});
				} else {
					$('#dlg').dialog('close'); // close the dialog
					$('#list_data').datagrid('reload'); // reload the user data
				}
			},
			error : function() {
				$.messager.show({
					title : 'Error',
					msg : "修改失败"
				});
			}
		});

	}
</script>
</head>
<body>
	<a href="javascript:upload()" class="easyui-linkbutton"
		iconCls="icon-add" plain="true">上传助管补助信息</a>
	<hr />
	<!-- 工具框 -->
	<div id="tb" style="padding: 3px">
		<a href="javascript:download()" class="easyui-linkbutton"
			iconCls="icon-undo" plain="true">提交已选</a>
	</div>
	<!-- 数据表框 -->
	<table id="list_data" style="width: 100%; height: auto;">
	</table>
	<script type="text/javascript">
		$('#list_data')
				.datagrid(
						{
							title : '未提交记录',
							iconCls : 'icon-save',//图标 
							nowrap : false,
							autoRowHeight : false,
							striped : true,//设置为true将交替显示行背景。
							border : true,
							collapsible : false,//是否可折叠的 
							fitColumns : true,
							checkOnSelect : false,
							fit : true,//自动大小 
							url : '/studentmanagement/yh/BZ_tmp/list_WTJ.do',
							//sortName : 'stuId',
							//sortOrder : 'asc',
							remoteSort : false,
							idField : 'stuId',
							singleSelect : false,//是否单选  设置为true将只允许选择一行。
							pagination : false,//设置true将在数据表格底部显示分页工具栏。 
							rownumbers : true,//行号 设置为true将显示行数。
							frozenColumns : [ [ {
								field : 'ck',
								checkbox : true
							} ] ],
							columns : [ [
									{
										field : 'id',
										title : '编号',
										width : 100,
										hidden : true
									},
									{
										field : 'stuId',
										title : '助管编号',
										width : 100,
									//sortable : true

									},
									{
										field : 'stuName',
										title : '姓名',
										width : 100,

									},

									{
										field : 'officeName',
										title : '设岗科室名称',
										width : 100
									},
									{
										field : 'bankName',
										title : '银行名称',
										width : 100
									},
									{
										field : 'bankNo',
										title : '银行卡号',
										width : 100
									},
									{
										field : 'stuTel',
										title : '联系电话',
										width : 100
									},
									{
										field : 'yearMonth',
										title : '申请年月',
										width : 100
									},
									{
										field : 'money',
										title : '申请金额',
										width : 100
									},
									{
										field : 'status',
										title : '状态',
										width : 100,
										formatter : function(value, row, index) {
											if (value == '0') {
												return "<span style='color:blue'>未提交</span>";
											} else {
												return "<span style='color:red'>提交失败</span>";
											}
										}
									},
									{
										field : 'beizhu',
										title : '备注',
										width : 100
									},
									{
										field : 'action',
										title : '操作',
										width : 100,
										align : 'center',
										formatter : function(value, row, index) {
											var s = '<button class="editRow" onclick="edit('
													+ index + ')">修改</button>';
											var c = '<button class="editRow" onclick="_delete('
													+ index + ')">删除</button>';
											return s + c;
										}
									} ] ],
							toolbar : '#tb'
						});
	</script>
	<!-- 下面的是创建或编辑对话框 -->
	<div Closed="true" id="dlg" class="easyui-dialog"
		data-options="modal:true,closed:true"
		style="width: 500px; height: 400px; padding: 10px 20px; font-size: 16px;"
		buttons="#dlg-buttons">
		<div class="ftitle">助管详细信息填写</div>
		<form id="fm" method="post">
			<table>
				<tr>
					<td></td>
					<td><input name="id" type="hidden"></td>
				</tr>
				<tr>
					<td>助管编 号:</td>
					<td><input name="stuId" class="easyui-validatebox"
						required="true"></td>
				</tr>
				<tr>
					<td>姓名:</td>
					<td><input name="name" class="easyui-validatebox"
						required="true">
				</tr>
				<tr>
					<td>设岗科室名称:</td>
					<td><input name="officeName">
				</tr>
				<tr>
					<td>银行名称:</td>
					<td><input name="bankName" class="easyui-validatebox"
						required="true" />
				</tr>
				<tr>
					<td>银行卡号:</td>
					<td><input name="bankNo" class="easyui-validatebox"
						required="true" />
				</tr>
				<tr>
					<td>联系电话:</td>
					<td><input name="tel">
				</tr>
				<tr>
					<td>申请年月:</td>
					<td><input name="yearMonth" class="easyui-validatebox"
						required="true" />规则：如201609
				</tr>
				<tr>
					<td>申请金额:</td>
					<td><input name="money" class="easyui-validatebox"
						required="true" />整数
				</tr>
				<tr>
					<td>备注:</td>
					<td><textarea name="beizhu" style="height: 60px; width: 200px"></textarea>
				</tr>
			</table>
		</form>
	</div>
	<!-- 创建或编辑对话框的里面的按钮 -->
	<div id="dlg-buttons">
		<a href="#" class="easyui-linkbutton" iconCls="icon-ok"
			onclick="save()">保存</a> <a href="#" class="easyui-linkbutton"
			iconCls="icon-cancel" onclick="javascript:$('#dlg').dialog('close')">退出</a>
	</div>
	<!-- 创建批量导入对话框 -->
	<div Closed="true" id="dlg_upload" class="easyui-dialog"
		data-options="modal:true,closed:true"
		style="width: 400px; height: 200px; padding: 10px 20px">
		<div class="ftitle">批量导入</div>
		<hr />
		<form id="fm_upload" method="post" enctype="multipart/form-data"
			action="/studentmanagement/yh/BZ_tmp/upload.do">
			选择文件： <input id="uploadExcel" name="uploadExcel" type="file" /> <a
				href="#" class="easyui-linkbutton" style="width: 40px"
				onclick="uploadExcel()">上传</a>

		</form>
		<hr />
		<div>
			<span>点击下载模板</span><a
				href="/studentmanagement/yh/BZ_tmp/downloadMB.do">模板</a>
		</div>
	</div>
</body>
</html>